package com.xiami.controller;

import com.xiami.pojo.MyResponseResult;
import com.xiami.pojo.User;
import com.xiami.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/*
创建者:虾米糖
*/
@RestController
@RequestMapping("/users")
public class UserController {
    @Autowired
    private UserService userService;
    @GetMapping("/{id}")
    public MyResponseResult getUser(@PathVariable Integer id){
      User user =  userService.list(id);
        return MyResponseResult.ok(user);
    }

    @PostMapping ()
    public MyResponseResult addUser(@RequestBody User user){
        userService.addUser(user);

        return MyResponseResult.builder().code(200).msg("ok").build();
    }
}
